//
//  ArticleCategoryVC.m
//  reSearchDemo
//
//  Created by 科技 on 15/8/18.
//  Copyright (c) 2015年 Kiwaro. All rights reserved.
//

#import "ArticleCategoryVC.h"
#import "PlatformFunctionCell.h"
@interface ArticleCategoryVC ()<UITableViewDataSource,UITableViewDelegate> {
    UITableView *_tableView;
    NSMutableArray *_dataSource;
    NSMutableArray *_cellArr;
}

@end

@implementation ArticleCategoryVC

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view.
    self.title = @"文章类别";
    self.navigationItem.rightBarButtonItem = [[UIBarButtonItem alloc] initWithTitle:@"编辑" style:UIBarButtonItemStyleDone target:self action:@selector(releaseBtnAction:)];
    _tableView = [[UITableView alloc] initWithFrame:CGRectMake(0, 0, CGRectGetWidth(self.view.frame), CGRectGetHeight(self.view.frame)) style:UITableViewStylePlain];
    _tableView.delegate = self;
    _tableView.dataSource = self;
    _tableView.tableFooterView = [[UIView alloc] init];
    
    [self.view addSubview:_tableView];
    [self loadModel];
}
#pragma mark --编辑按钮点击事件--
-(void)releaseBtnAction:(UIBarButtonItem *)sender {

}
//加载数据
-(void)loadModel {
    NSArray *textArr = @[@"内科",@"外科",@"中医"];
    NSArray *imageArr = @[@"图标1",@"图标2",@"图标3"];
    
    _dataSource = [NSMutableArray array];
    _cellArr = [NSMutableArray array];
    for (int i = 0; i<textArr.count; i++) {
        NSMutableDictionary *dic = [NSMutableDictionary dictionary];
        [dic setObject:textArr[i] forKey:@"text"];
        [dic setObject:imageArr[i] forKey:@"image"];
        
        [_dataSource addObject:dic];
        
        PlatformFunctionCell *cell = [[PlatformFunctionCell alloc] init];
        [_cellArr addObject:cell];
    }
    
}
#pragma mark --tableViewDelegate--
-(NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
    return _dataSource.count;
}
-(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
    static NSString *indentifier = @"cell";
    PlatformFunctionCell *cell = [tableView dequeueReusableCellWithIdentifier:indentifier];
    if (!cell) {
        cell = [[PlatformFunctionCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:indentifier];
    }
    
    cell.model = _dataSource[indexPath.row];
    cell.accessoryType = UITableViewCellAccessoryDisclosureIndicator;
    return cell;
}
-(CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath {
    PlatformFunctionCell *cell = _cellArr[indexPath.row];
    cell.model = _dataSource[indexPath.row];
    
    return cell.height;
}
-(void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
    [tableView deselectRowAtIndexPath:indexPath animated:YES];
}
- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
